package com.jiezuo.auth.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;

import com.jiezuo.auth.entity.LoginLog;
import com.jiezuo.auth.service.LoginLogService;
import com.jiezuo.common.base.BaseController;
import com.jiezuo.common.util.PageUtil;
import com.jiezuo.common.util.ResultUtil;
import com.jiezuo.common.vo.PageVo;
import com.jiezuo.common.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* @description   登陆日志
* @author        庞留杰
* @date          2021/12/01 14:08
* @version       V1.0
**/
@Slf4j
@Transactional
@RequestMapping("/loginLog")
@RestController
//登陆日志", tags = {"登陆日志接口"})
public class LoginLogController  extends BaseController{

    @Autowired
    private LoginLogService service;

    //查询带分页列表", notes = "查询带分页列表")
    @GetMapping("/findPage")
    public Result<IPage<LoginLog>> findPage(@ModelAttribute PageVo pageVo, @ModelAttribute LoginLog loginLog) {
        IPage<LoginLog> page = service.findPage(PageUtil.initMpPage(pageVo),loginLog);
        return new ResultUtil<IPage<LoginLog>>().setData(page);
    }

    //查询不带分页列表", notes = "查询不带分页列表")
    @GetMapping("/findList")
    public Result<List<LoginLog>> findList(@ModelAttribute LoginLog loginLog) {
        List<LoginLog> list = service.findList(loginLog);
        return new ResultUtil<List<LoginLog>>().setData(list);
    }

//    //通过ID查询", notes = "通过ID查询")
//    //s({
//        //(name = "id", value = "ID", dataType = "String", required = true, paramType = "query")
//    })
//    @GetMapping("/findById")
//    public Result<LoginLog> findById(String id) {
//        LoginLog loginLog = service.findById(id);
//        return new ResultUtil<LoginLog>().setData(loginLog);
//    }
//
//    //添加", notes = "添加")
//    @ApiOperationSupport(ignoreParameters = {
//        "id", "created_by", "created_time", "updated_by", "updated_time", "is_delete"
//    })
//    @PostMapping("/save")
//    public Result save(@RequestBody LoginLog loginLog) {
//        boolean boo = service.add(loginLog);
//        if(boo){
//            return new ResultUtil().setSuccessMsg(ResultEnums.OK.getReasonPhraseCN());
//        }else {
//            return new ResultUtil().setErrorMsg(ResultEnums.FAIL.getReasonPhraseCN());
//        }
//    }
//
//    //修改", notes = "修改")
//    @ApiOperationSupport(ignoreParameters = {
//        "created_by", "created_time", "updated_by", "updated_time", "is_delete"
//    })
//    @PostMapping("/update")
//    public Result update(@RequestBody LoginLog loginLog) {
//        boolean boo = service.update(loginLog);
//        if(boo){
//            return new ResultUtil().setSuccessMsg(ResultEnums.OK.getReasonPhraseCN());
//        }else {
//            return new ResultUtil().setErrorMsg(ResultEnums.FAIL.getReasonPhraseCN());
//        }
//    }
//
//    //删除", notes = "删除【逻辑删除】")
//    @PostMapping("/delete/{id}")
//    public Result delete(@PathVariable String id) {
//        boolean boo = service.delete(id);
//        if(boo){
//            return new ResultUtil().setSuccessMsg(ResultEnums.OK.getReasonPhraseCN());
//        }else {
//            return new ResultUtil().setErrorMsg(ResultEnums.FAIL.getReasonPhraseCN());
//        }
//    }

}
